Language Elements and Expressions > Numbers

Numbers

ProModel uses two types of numbers: real numbers and integers. ProModel also uses a special category of integers, called “name-index numbers.” This section discusses real numbers, integers, and name-index numbers. It then discusses converting between the different types.

Integers

An integer number is a whole number ranging from -2,147,483,648 to 2,147,483,647. Integer values may not include commas. Therefore, the number 5,380 should be entered as 5380. Name-index numbers (described in this section) work just like integer numbers.

Examples of integers

-2234798

0

32

Real Numbers

A real number is any number ranging from 1.7 X 10 -308 to 1.7 X 10 +308, including decimals. Real values may not include commas. As such, the number 5,380.5 should be entered as 5380.5.

Examples of real numbers

-2.875638

844.2

65.0

Name-Index Numbers

When a simulation begins, locations, resources, and entities are all assigned numbers according to their position in their respective edit tables. The number assigned to the element is called its name-index number. For example, the third entity in the Entity edit table will have the number three for its name index number. The name of an element may be used in an expression to reference its name-index number.

 

For example, if EntityA were the third entity in the Entity edit table, the statement, “Attr1 = EntityA,” would assign the number three to Attr1, because attributes take numbers. Additionally, you may also test for an index number by referencing the element name with a statement like, “IF Var5 = Location3 THEN.” In fact, when using a name-index number to identify a location, resource, or entity (as in the previous examples), it is usually best to use the name of the element, because inserting or deleting an element from the edit table, may change the name-index number assigned to other elements.

 

If you need to refer to a location, resource, or entity by name but only know its name-index number, use the name functions: LOC(), RES(), and ENT(). These functions allow name-index numbers and variables or attributes containing name-index numbers to be converted back to their actual names for use in statements or expressions requiring the element name.

 

Consider the statement, “Attr1 = PASSENGER.” Although this statement only stores the name index number of the element in the attribute, the name-index number can then be used in conjunction with LOC(), ENT(), and RES() to get the actual name of the location. For example, if PASSENGER is the fifth entity in the Entity edit table, the statement JOIN 1 ENT(Attr1) works the same as JOIN 1 PASSENGER. Additionally, a name-index number can be used with the name functions to output a name to the screen or a file.

Converting Between Numeric Types

When an expression expects one type of value but receives another, ProModel automatically takes care of converting between the two, so most often the difference will not matter. However, when ProModel expects an integer but receives a real value, it truncates the real value at the decimal point. For example, say the variable Integer1 is assigned the value 3.9, as in the following statement: Integer1=3.9. The variable Integer1 would hold the value 3, not 4. To round 3.9 when assigning to an integer variable would require the statement, Integer1=Round(3.9).

 

Converting from name-index numbers to the name of an element requires the ENT(), LOC(), and RES() functions as ProModel does not automatically convert numbers to names. For information on how to output the name of an element based on its name-index number, see String Expressions.


© 2012 ProModel Corporation • 556 East Technology Avenue • Orem, UT 84097 • Support: 888-776-6633 • www.promodel.com